#include "tablesymb.h"

bool t_isnumeric(Type t) {
	return t == t_int || t == t_float;
}

char const* pp_type(Type t) {
	switch (t) {
		case t_no: return "t_no";
		case t_int: return "t_int";
		case t_float: return "t_float";
		case t_bool: return "t_bool";
		case t_chaine: return "t_chaine";
		case t_char: return "t_char";
		case t_tab: return "t_tab";
		case t_list: return "t_list";
		case t_objet: return "t_objet";
		case t_void: return "t_void";
		default: return "not a type";
	}
}

// Helper functions
bool id_isconstant(char const* s) {
	int i, len = strlen(s);
	for (i = 0; i < len; i++) {
		if (isalpha(s[i]) && !isupper(s[i])) return false;
	}
	return true;
}

Nature id_getnature(char const* s) {
    if (id_isinstance(s)) return n_var_inst;
    if (id_isglobal(s)) return n_var_glob;
    else return n_var_loc;
}

bool id_isinstance(char const* s) {
    return s[0] == '@';
}

bool id_isglobal(char const* s) {
    return s[0] == '$';
}

bool id_isclass(char const* s) {
    return isupper(s[0]);
}

char const* pp_nature(Nature n) {
	switch (n) {
		case n_var_loc: return "n_var_loc";
		case n_var_inst: return "n_var_inst";
		case n_var_glob: return "n_var_glob";
		default: return "not a nature";
	}
}
